﻿using System;

namespace UIOC.Attributes;

///// <summary>
///// 接口将被自动实现为一个类
///// </summary>
//[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
//public sealed class AutoImplementAttribute(Type baseType = null) : Attribute {

//    public Type BaseType { get; } = baseType;
//}

//[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
//public sealed class AutoImplementFieldAttribute(Type fieldType = null) : Attribute {

//    public Type FieldType { get; } = fieldType;
//}

//[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
//public sealed class InterfacePropertyAttribute(Type interfaceType, string propertyName) : Attribute {

//    public Type InterfaceType { get; } = interfaceType;

//    public string PropertyName { get; } = propertyName;
//}

/// <summary>
/// 标记类所实现的接口类型。
/// </summary>
/// <param name="interfaceType">实现的接口类型。</param>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class ImplementAttribute(Type interfaceType) : Attribute {

    /// <summary>
    /// 获取实现的接口类型。
    /// </summary>
    public Type InterfaceType { get; } = interfaceType;
}

/// <summary>
/// 表示依赖对象的实例类型。
/// </summary>
public enum InstanceType {

    /// <summary>
    /// 普通对象，每次获取时创建新实例。
    /// </summary>
    Default = 0,

    /// <summary>
    /// 全局唯一实例（单例对象），整个应用生命周期只创建一次。
    /// </summary>
    Singleton = 1,
}

/// <summary>
/// 用于标记类的实例类型（普通对象或单例）。
/// </summary>
/// <remarks>
/// 通过此特性可指定类的实例类型，配合 <see cref="InstanceType"/> 枚举使用。
/// </remarks>
/// <param name="value">实例类型枚举值，指定对象创建类型。</param>
[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
public class InstanceTypeAttribute(InstanceType value) : Attribute {

    /// <summary>
    /// 获取实例类型（普通对象或单例）。
    /// </summary>
    public InstanceType Value { get; } = value;
}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class AutowiredAttribute : Attribute {
}

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class BeanRegisterAttribute(Type objectType) : Attribute {

    public Type ObjectType { get; } = objectType;
}

[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public sealed class InternalAttribute : Attribute {
}

/// <summary>
/// 标记此类型及其成员不进行 Internal 访问性检查
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
public sealed class SkipInternalValidationAttribute : Attribute {
}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class FileFieldAttribute : Attribute {
}

//public enum InterceptionStage {
//    Enter = 1,
//    Exit = 2,
//    All = Enter | Exit,
//}

///// <summary>
///// 切面
///// </summary>
//public abstract class AspectAttribute(InterceptionStage interceptionStage, int order = 0) : Attribute {

//    public InterceptionStage InterceptionStage { get; } = interceptionStage;

//    public int Order { get; } = order;
//}